home *** CD-ROM | disk | FTP | other *** search
/ PC World 2006 December / PCWorld_2006-12_cd.bin / v cisle / robocopy / rktools.exe / RCDATA / CABINET / rktools.msi / checkrepl.vbs < prev    next >
Text File  |  2003-04-18  |  6KB  |  188 lines

  1. '---------------------------------------------------------
  2. '
  3. '  checkrepl.vbs      
  4. '
  5. '    Monitor Windows 2000 
  6. '    Active Directory Replication
  7. '
  8. '    mattraff 11/20/2002
  9. '
  10. '---------------------------------------------------------
  11.  
  12. Sub help()
  13.     WScript.Echo ""
  14.     WScript.Echo "Monitor replication and enumerate the"
  15.     WScript.Echo "replication topology for a given DC."
  16.     WScript.Echo ""
  17.     WScript.Echo "usage:"
  18.     WScript.Echo "======"  
  19.     WScript.Echo "cscript checkrepl.vbs server"
  20.     WScript.Echo ""
  21.     WScript.Echo "eg:"
  22.     WScript.Echo "==="     
  23.     WScript.Echo "cscript checkrepl.vbs corpdc01"   
  24.     WScript.Echo ""
  25.     WScript.Echo "Note: This script requires that the Resource Kit tool, iadstools.dll be registered on the local machine."
  26.    
  27.     WScript.Quit
  28. End Sub    
  29.     
  30.  
  31. Set objArgs = WScript.Arguments
  32.  
  33. Select Case objArgs.Count
  34.     Case 0
  35.         help
  36.     Case 1
  37.         Select Case objArgs(0)
  38.             Case "-?"
  39.                 help
  40.                
  41.             Case "?"
  42.                 help
  43.  
  44.             Case "/?"
  45.                 help              
  46.                                
  47.             Case Else
  48.  
  49.                 
  50.         End Select
  51.     Case Else
  52. End Select
  53.  
  54.  
  55. Dim site
  56. Dim objSite
  57. Dim DSACon
  58. Dim nameList
  59. Dim partitionResult
  60. Dim nc
  61. Dim outboundCount
  62. Dim outboundPartners
  63. Dim Partners
  64.  
  65. Dim server
  66. Dim isPartialNC
  67.  
  68. Set Wshshell = Wscript.CreateObject("Wscript.shell")
  69.  
  70. server = objArgs(0)
  71.  
  72. Set DLL=CreateObject("IADsTools.DCFunctions")
  73.  
  74. 'Use iads getSiteForServer to get the TS Server's site.
  75. site=DLL.getSiteForServer(CStr(server),0)
  76. If site = "" Then
  77.   WScript.Echo ""
  78.   WScript.Echo DLL.LastErrorText
  79.   WScript.Quit
  80. End If
  81.  
  82.  
  83. 'Get the number of connections For this server and the server names
  84. DSACon=DLL.GetDSAConnections(CStr(server), CStr(site) , CStr(server), 0)
  85. 'Or... 
  86. ' If you want to direct the query to a specific server you can specify that server in the following line
  87. 'DSACon=DLL.GetDSAConnections("Server Name", CStr(site) , CStr(server), 0)
  88.  
  89. WScript.Echo ""  
  90. WScript.Echo "Inbound Neighbors"
  91. WScript.Echo "" 
  92.  
  93. For i =  1 to DSACon
  94.   nameList=DLL.DSAConnectionServerName(i) 
  95.   WSCript.Echo "  " & i & ")  " & CStr(nameList) 
  96. Next
  97.  
  98. 'Go through the connections one by one and get what info we can
  99. 'For i = 1 to DSACon
  100.  
  101. WScript.Echo "" 
  102.  
  103. 'Get writable NC's
  104.     partitionResult=DLL.GetNamingContexts(objArgs(0))
  105.     For j=1 to partitionResult
  106.     
  107.       nc = DLL.NamingContextName(j)
  108.       
  109.       Partners=DLL.GetDirectPartners(CStr(server), DLL.NamingContextName(j))
  110.       WScript.Echo ""
  111.       WScript.Echo DLL.ConvertLDAPToDNS(DLL.NamingContextName(j))
  112.       For k=1 to Partners
  113.         WScript.Echo "    " & DLL.DirectPartnerName(k) & " via " & DLL.DirectPartnerTransportDN(k)
  114.  
  115.         'see if there's a failure code other than zero for any of the replication partners       
  116.         If DLL.DirectPartnerFailReason(k) > 0 then
  117.           wscript.echo "        Failure replicating partition " + DLL.NamingContextName(j)
  118.           WScript.Echo "            @ " & DLL.DirectPartnerLastAttemptTime(k)
  119.           WScript.Echo "            Error: " & DLL.ConvertErrorMsg(DLL.DirectPartnerFailReason(k))
  120.           WScript.Echo "              " & DLL.DirectPartnerNumberFailures(k) & "consecutive failures."
  121.           WScript.Echo "               Last successful attempt was @ " & DLL.DirectPartnerLastSuccessTime(k)  
  122.           WScript.Echo "               Current through property update USN : " & DLL.DirectPartnerHighPU(k)                  
  123.         Else
  124.           wscript.echo "        Last successful attempt: " & DLL.DirectPartnerLastSuccessTime(k)
  125.           WScript.Echo "            Current through property update USN : " & DLL.DirectPartnerHighPU(k)
  126.         End if        
  127.         
  128.       Next      
  129.       
  130.       'Why was this connection generated?        
  131.       'Reason=DLL.DSAConnectionReasonCode(i, j)
  132.       'WSCript.Echo "         Reason for connection:  " & Reason   
  133.     Next
  134.  
  135.   
  136.     'Get partial NC's for GC's
  137.     PartialPartitionResult=DLL.GetPartialNamingContexts(objArgs(0))
  138.     WScript.Echo "" 
  139.  
  140.     ' Check to see if we even have any partial NC's to worry about
  141.     If PartialPartitionResult = 0 Then
  142.  
  143.     Else
  144.     
  145.       For j=1 to PartialPartitionResult
  146.         Partners=DLL.GetDirectPartners(CStr(server), DLL.NamingContextName(j))
  147.         WScript.Echo ""
  148.         WScript.Echo DLL.ConvertLDAPToDNS(DLL.NamingContextName(j))
  149.         For k=1 to Partners
  150.         WScript.Echo "    " & DLL.DirectPartnerName(k) & " via " & DLL.DirectPartnerTransportDN(k)
  151.           
  152.         'see if there's a failure code other than zero for any of the replication partners       
  153.         If DLL.DirectPartnerFailReason(k) > 0 then
  154.           wscript.echo "        Failure replicating partition " + DLL.NamingContextName(j)
  155.           WScript.Echo "            @ " & DLL.DirectPartnerLastAttemptTime(k)
  156.           WScript.Echo "            Error: " & DLL.ConvertErrorMsg(DLL.DirectPartnerFailReason(k))
  157.           WScript.Echo "              " & DLL.DirectPartnerNumberFailures(k) & "consecutive failures."
  158.           WScript.Echo "               Last successful attempt was @ " & DLL.DirectPartnerLastSuccessTime(k)           
  159.           WScript.Echo "               Current through property update USN : " & DLL.DirectPartnerHighPU(k)          
  160.         Else
  161.           wscript.echo "        Last successful attempt: " & DLL.DirectPartnerLastSuccessTime(k)
  162.           WScript.Echo "            Current through property update USN : " & DLL.DirectPartnerHighPU(k)
  163.         End If
  164.         
  165.         Next  
  166.         'Why was this connection generated?  
  167.         'Reason=DLL.DSAConnectionReasonCode(i, j)
  168.         'WSCript.Echo "         Reason for connection:  " & Reason           
  169.       Next
  170.       
  171.      
  172.     End If
  173.  
  174. 'Next
  175.  
  176. 'Enumerate Outbound replication partners.
  177. outboundCount=DLL.GetChangeNotifications(CStr(server), CStr(nc), 0, 0)
  178.  
  179. WScript.Echo ""
  180. WScript.Echo "Outbound Neighbors:"
  181. WScript.Echo ""
  182.  
  183. For l = 1 to outboundCount
  184.  
  185.   WScript.Echo "  " & DLL.NotificationPartnerName(l) & " via " & DLL.NotificationPartnerTransport(l)
  186.   WScript.Echo "        Object GUID: " & DLL.NotificationPartnerObjectGuid(l)  
  187.   
  188. Next